package com.niuwa.p2p.action.channel;

import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.niuwa.p2p.core.mvc.entity.JsonResult;
import com.niuwa.p2p.core.mvc.entity.PageBean;
import com.niuwa.p2p.opr.utils.SessionUtil;
import com.niuwa.p2p.service.channel.IChannelImgVideoService;
import com.niuwa.p2p.vo.channel.ChannelVideoNwFileVo;

public class ChannelImgVideoAction extends ChannelCommonAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 7335534840522646802L;
	@Autowired
	private IChannelImgVideoService channelImgVideoService;

	private String fileID;
	
	private String corpCode;

	/**
	 * 影像文件列表显示
	 * 
	 * @return
	 */
	@Action(value = "listImgVideo")
	public String listImgVideo() {
		// 获取Grid条件选择参数
		Map<String, Object> paramMap = getParamMap();
		// 执行查询操作
		PageBean<ChannelVideoNwFileVo> page = channelImgVideoService
				.searchChannelImgVideoRecord(paramMap);
		// 设置返回
		setObjectReSult(page);
		return NONE;
	}

	/**
	 * 保存影像文件记录到本地数据库
	 * 
	 * @return
	 */
	@Action("saveImgVideo")
	public String saveImgVideo() {
		// 从session中那user
		// 得到当前用户
		String message = "文件上传失败，请重试";
		if (!corpCode.isEmpty()) {
			channelImgVideoService.saveImgVideo(getFileID(), corpCode,
					SessionUtil.getSessionUser());
			message = "你已成功上传文件";
		}
		JsonResult result = new JsonResult();
		result.setMsg(message);
		this.setResult(result);
		return NONE;
	}

	/**
	 * 假删除本地影像文件记录
	 * 
	 * @return
	 */
	@Action("deleteImgVideo")
	public String deleteImgVideo() {
		String message = "文件删除失败";
		channelImgVideoService.deleteImgVideo(getFileID(), corpCode);
		message = "你已成功删除文件";
		JsonResult result = new JsonResult();
		result.setMsg(message);
		this.setResult(result);
		return NONE;
	}


	public String getCorpCode() {
		return corpCode;
	}

	public void setCorpCode(String corpCode) {
		this.corpCode = corpCode;
	}

	public String getFileID() {
		return fileID;
	}

	public void setFileID(String fileID) {
		this.fileID = fileID;
	}


}
